import { RouteRecordRaw, createRouter, createWebHashHistory } from 'vue-router';
import Login from '@/pages/login.vue';
import Home from '@/pages/home.vue';

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: '首页',
    component: Home,
    children: [
      {
        path: '',
        name: '首页-推荐',
        meta: {
          headerTitle: '欢迎，今天又是美好的一天哦～',
          isRoot: true,
          funcs: ['user']
        },
        component: () => import('@/pages/home/recommend.vue')
      },
      {
        path: 'game',
        name: '首页-互动',
        meta: {
          isRoot: true
        },
        component: () => import('@/pages/home/game.vue'),
      },
      {
        path: 'share',
        name: '首页-分享',
        meta: {
          isRoot: true
        },
        component: () => import('@/pages/home/share.vue'),
      },
      {
        path: 'userProfile/:userId',
        name: '用户详情',
        meta: {
          funcs: ['cart'],
        },
        component: () => import('@/pages/home/userProfile.vue'),
      }
    ]
  },
  {
    path: '/login',
    name: '用户登录',
    component: Login
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: routes,
})

export default router;